package com.lovo.view.emp;

import com.lovo.javafxComponent.*;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.layout.Pane;

/**
 * 修改员工信息
 * @author lovo
 */
public class UpdateEmpDialog extends Dialog {
    /**内容容器*/
    private Pane container = new Pane();

    /**姓名文本框*/
    private LovoTxt nameTxt = new LovoTxt("姓名", 80, 100,container);
    /**性别文本框*/
    private LovoRadioButton genderRadio = new LovoRadioButton("性别", new String[]{"男","女"}, 80, 150,container);
    /**文化程度文本框*/
    private LovoTxt educationTxt = new LovoTxt("文化程度", 80, 200,container);
    /**出生日期文本框*/
    private LovoDate bornDate = new LovoDate("出生日期", 80, 250,container);
    /**联系电话文本框*/
    private LovoTxt phoneTxt = new LovoTxt("联系电话", 80, 300,container);
    /**所在部门文本框*/
    private LovoComboBox deptComboBox = new LovoComboBox("所在部门",new String[]{"开发部","市场部"}, 80, 350,container);

    /**头像*/
    private LovoImage faceImg;
    /**图片选择器*/
    private LovoImageFileChooser fileChooser;
    /**学校主面板*/
    private EmpPane empPane;
    /**
     * 构造方法
     */
    public UpdateEmpDialog(EmpPane empPane) {
        this.empPane = empPane;
        this.setTitle("修改员工");
        initComponent();
    }

    /**
     * 初始化组件
     */
    private void initComponent() {
        new LovoTitle("修改员工", -150, 30, container);
        container.setPrefSize(580, 450);
        this.getDialogPane().setContent(container);

        this.initInfo();
        fileChooser = new LovoImageFileChooser(380, 100, 180, 220, container);


        ButtonType addButtonType = new ButtonType("修改", ButtonData.YES);
        this.getDialogPane().getButtonTypes().add(addButtonType);
        Button updateBtn = (Button) this.getDialogPane().lookupButton(addButtonType);

        updateBtn.addEventFilter(ActionEvent.ACTION, event -> {
            if(updateEmp() == false) {
                event.consume();
            }
        });

        ButtonType cancelButtonType = new ButtonType("取消", ButtonData.CANCEL_CLOSE);
        this.getDialogPane().getButtonTypes().add(cancelButtonType);

        this.showAndWait();
    }

    //------------------------

    /**
     * 添加
     * @return 添加是否成功
     */
    private boolean updateEmp() {
        if(check() == false){
            return false;
        }
        return true;
    }

    private boolean check(){
        return  true;
    }

    /**
     * 初始化下拉框信息
     */
    private void initInfo() {

    }



}
